#ifndef _SESSIONTRACKER_
#define _SESSIONTRACKER_

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <list>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>

#include "SwafStructs.h"
#include "ConfigFile.h"
#include "SharedQueue.h"
using namespace std;

#define MIN_HTTP_DATA_TO_HANDLE 10

//#define DEBUG_SESSION_TRACKER

class SessionTracker
{
private:
	string _rawData;
	SharedQueue<struct RAWIPDATA> *_snifferQueue;           // pointer to the sniffer queue
	map<string,struct HTTP_SESSION> *_httpSessionsTable;   // pointer to the http sessions table
	int _numIPPackets;                                    // the number of IP packets the sessions tracker had handled
	time_t _sessionTimeToLive;                           // in case no packet came for that session for _sessionTimeToLive - drop the session
	int _maxSessions;									// max number of http sessions supported
	int _numPackets;								   // the number of packets handled by the SessionTracker
	u_short _serverPort; 								  // the server port number

public:
	SessionTracker(SharedQueue<struct RAWIPDATA>*,map<string,struct HTTP_SESSION>*);
	virtual ~SessionTracker();
	void run();
	void init();
	void setSessionId(struct TCP_PARAMS&,string&);
	int parseRawData(struct RAWIPDATA&,struct TCP_PARAMS&,struct SEQACK_PARAMS&,u_char**);
	void printSessionsTable();
	void printSessionsToFile();
	void printtofile(string&);
	void getServerPort();

};
#endif// _SESSIONTRACKER_


